package Servlet;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import dao.UpdateReservationStatus;

public class updateReservationStatusServlet extends HttpServlet {

    @Override
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setHeader("Cache-Control", "no-cache");
        response.setContentType("text/html;charset=utf-8");
        PrintWriter out = response.getWriter();
        String appointmentNumber = request.getParameter("appointmentNumber");
        String appointmentCheckStatus = request.getParameter("appointmentCheckStatus");
        int res = -1;
        if (appointmentNumber != null || appointmentCheckStatus != null) {
            res = UpdateReservationStatus.updateStatus(appointmentNumber, Integer.parseInt(appointmentCheckStatus));
        }
        out.print(res);
    }

    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}
